package dk.itu.mobile.server;

import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;

public class ItuConnector {
	private static JSch jsch;
	private static String HOST = "ssh.itu.dk";
	
	public static boolean authenticate(String user, String pass) {
		jsch = new JSch();
		
		if ( pass == null || user == null ) {
			return false;
		}
		try {
			Session session = jsch.getSession(user, HOST, 22);
			session.setPassword(pass);
			session.setConfig("StrictHostKeyChecking", "no");
			session.connect();
			System.out.println("Got connection, user is authenticated");
			session.disconnect();
			return true;
		} catch (JSchException e) {
			System.out.println("Did not get connection, check credentials");
		}
		return false;
	}
	
}
